package com.cls.business.factory;

import com.cls.business.service.INoticeService;
import com.cls.business.service.impl.NoticeServiceImpl;
import com.cls.business.strategy.NoticeStrategy;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 魏起成
 * 创建通知公告的工厂模式获取真正处理的服务类
 *
 * @author Administrator
 */
@Service
public class NoticeFactory {
    @Autowired
    private final Map<String, NoticeStrategy> noticeStrategyMap = new ConcurrentHashMap<>();

    public NoticeStrategy getStrategy(String serviceName) {
        NoticeStrategy strategy = noticeStrategyMap.get(serviceName);
        if (strategy == null) {
            //如果没有则返回通知公告的服务
            return noticeStrategyMap.get("notice_type_ptgg");
        }
        return strategy;
    }

}
